﻿Public Class frmVentas

    
    Private Sub frmVentas_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'frmIndex.Hide()
        For i = 0 To 100
            cboLoteNum.Items.Add(i)
        Next i

        puntajeTotalVTA = 0
        CargarEmpresas(cbo_empresa)
        CargarAuditor(cbo_controla)
        CargarTllamada(cbo_tllamada)
        CargarOptSaluVta(cbo_salu)
        CargarOptEmpaVta(cbo_empatia)
        CargarOptIndVta(cbo_indagacion)
        CargarOptManVta(cbo_manejo)
        CargarOptEntVta(cbo_entusiasmo)
        CargarOptSpeechVta(cbo_speech)
        CargarOptPresVta(cbo_presentacion)
        CargarOptMecVta(cbo_mecanismo)
        CargarOptPideVta(cbo_pide)
        dtp_hoy.Value = Today
        lbl_puntaje.Text = puntajeTotalVTA
        TodoACero()
    End Sub
    Private Sub bt_guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_guardar.Click
        Dim controles As String
        controles = ""
        controles = ControlCamposIncompletos(Gb_01) + controles
        controles = ControlCamposIncompletos(Gb_03) + controles

        If controles <> "" Then
            MsgBox("Le falto completar datos en: " & Chr(13) & controles, MsgBoxStyle.Critical, "ERROR!")
        Else
            IDentificadorUnico(lblIdunicoLlam)
            titulo(Gb_01)
            titulo(Gb_02)
            If chkAlerta.Checked = True Then
                Dim correoDestino As String
                correoDestino = getEmailDestino(cbo_empresa.Text)
                enviarAlerta(correoDestino, cbo_controla.Text, cbo_auditado.Text, txtCaso.Text, cboLoteLetra.Text + cboLoteNum.Text, dtp_fllam.Text, lbl_puntaje.Text, rtxt_encontra.Text)
            End If
            Dim guardar As New C_agregarDatosVentas
            guardar.guardarLLamada()
            TodoACero()
        End If

    End Sub
    Private Sub bt_nAuditado_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmNewAuditado.ShowDialog()
    End Sub
    Private Sub bt_nControler_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmNewControlador.ShowDialog()
    End Sub
    Private Sub cbo_salu_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_salu.SelectedIndexChanged
        Dim valorSal As New C_todosVentas
        PsaludoVTA = valorSal.valorSalu(cbo_salu)
        txtv01.Text = PsaludoVTA
        puntajeTotalVTA = 0
        puntajeTotalVTA = PsaludoVTA + PempatiaVTA + PindagacionVTA + PmanejoVTA + PentusiasmoVTA + PspeechVTA + PpresentacionVTA + PmecanismoVTA + PpideVTA
        lbl_puntaje.Text = puntajeTotalVTA
    End Sub
    Private Sub cbo_empatia_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_empatia.SelectedIndexChanged
        Dim valorEmp As New C_todosVentas
        PempatiaVTA = valorEmp.valorEmpatia(cbo_empatia)
        txtv02.Text = PempatiaVTA
        puntajeTotalVTA = 0
        puntajeTotalVTA = PsaludoVTA + PempatiaVTA + PindagacionVTA + PmanejoVTA + PentusiasmoVTA + PspeechVTA + PpresentacionVTA + PmecanismoVTA + PpideVTA
        lbl_puntaje.Text = puntajeTotalVTA
    End Sub
    Private Sub cbo_indagacion_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_indagacion.SelectedIndexChanged
        Dim valorInd As New C_todosVentas
        PindagacionVTA = valorInd.valorIndagacion(cbo_indagacion)
        txtv03.Text = PindagacionVTA
        puntajeTotalVTA = 0
        puntajeTotalVTA = PsaludoVTA + PempatiaVTA + PindagacionVTA + PmanejoVTA + PentusiasmoVTA + PspeechVTA + PpresentacionVTA + PmecanismoVTA + PpideVTA
        lbl_puntaje.Text = puntajeTotalVTA
    End Sub
    Private Sub cbo_disposicion_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_manejo.SelectedIndexChanged
        Dim valorManejo As New C_todosVentas
        PmanejoVTA = valorManejo.valorManejo(cbo_manejo)
        txtv04.Text = PmanejoVTA
        puntajeTotalVTA = 0
        puntajeTotalVTA = PsaludoVTA + PempatiaVTA + PindagacionVTA + PmanejoVTA + PentusiasmoVTA + PspeechVTA + PpresentacionVTA + PmecanismoVTA + PpideVTA
        lbl_puntaje.Text = puntajeTotalVTA
    End Sub
    Private Sub cbo_compromiso_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_entusiasmo.SelectedIndexChanged
        Dim valorEntu As New C_todosVentas
        PentusiasmoVTA = valorEntu.valorEntusiasmo(cbo_entusiasmo)
        txtv05.Text = PentusiasmoVTA
        puntajeTotalVTA = 0
        puntajeTotalVTA = PsaludoVTA + PempatiaVTA + PindagacionVTA + PmanejoVTA + PentusiasmoVTA + PspeechVTA + PpresentacionVTA + PmecanismoVTA + PpideVTA
        lbl_puntaje.Text = puntajeTotalVTA
    End Sub
    Private Sub cbo_info_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_speech.SelectedIndexChanged
        Dim valorSpeech As New C_todosVentas
        PspeechVTA = valorSpeech.valorSpeech(cbo_speech)
        txtv06.Text = PspeechVTA
        puntajeTotalVTA = 0
        puntajeTotalVTA = PsaludoVTA + PempatiaVTA + PindagacionVTA + PmanejoVTA + PentusiasmoVTA + PspeechVTA + PpresentacionVTA + PmecanismoVTA + PpideVTA
        lbl_puntaje.Text = puntajeTotalVTA
    End Sub
    Private Sub cbo_comunicacion_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_presentacion.SelectedIndexChanged
        Dim valorPresent As New C_todosVentas
        PpresentacionVTA = valorPresent.valorPresentacion(cbo_presentacion)
        txtv07.Text = PpresentacionVTA
        puntajeTotalVTA = 0
        puntajeTotalVTA = PsaludoVTA + PempatiaVTA + PindagacionVTA + PmanejoVTA + PentusiasmoVTA + PspeechVTA + PpresentacionVTA + PmecanismoVTA + PpideVTA
        lbl_puntaje.Text = puntajeTotalVTA
    End Sub
    Private Sub cbo_credibilidad_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_mecanismo.SelectedIndexChanged
        Dim valorMeca As New C_todosVentas
        PmecanismoVTA = valorMeca.valorMecanismo(cbo_mecanismo)
        txtv08.Text = PmecanismoVTA
        puntajeTotalVTA = 0
        puntajeTotalVTA = PsaludoVTA + PempatiaVTA + PindagacionVTA + PmanejoVTA + PentusiasmoVTA + PspeechVTA + PpresentacionVTA + PmecanismoVTA + PpideVTA
        lbl_puntaje.Text = puntajeTotalVTA
    End Sub
    Private Sub cbo_cierre_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_pide.SelectedIndexChanged
        Dim valorPide As New C_todosVentas
        PpideVTA = valorPide.valorPide(cbo_pide)
        txtv09.Text = PpideVTA
        puntajeTotalVTA = 0
        puntajeTotalVTA = PsaludoVTA + PempatiaVTA + PindagacionVTA + PmanejoVTA + PentusiasmoVTA + PspeechVTA + PpresentacionVTA + PmecanismoVTA + PpideVTA
        lbl_puntaje.Text = puntajeTotalVTA
    End Sub
    Private Sub LlamadasPorNºDeLoteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmInfoAsesorAtencion.ShowDialog()
    End Sub
    Private Sub bt_nEmpresa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frm_empresa.ShowDialog()
    End Sub
    Private Sub cbo_empresa_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        auditadosXempresaVentas(cbo_auditado, cbo_empresa.Text)
    End Sub
    Private Sub dtp_fllam_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If dtp_fllam.Value > Today Then
            MsgBox("La fecha de llamada no puede ser mayor al día Actual")
            dtp_fllam.Value = Today
        End If
    End Sub
    Private Sub EditarLlamadasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmSearchLlamadas.ShowDialog()
    End Sub
    Private Sub RankingDePromediosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmInfoRankingAtencion.ShowDialog()
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim yes As Integer
        yes = MsgBox("Seguro desea salir de la auditoria de VENTAS?" & Chr(13) & "Los datos se perderan al no ser guardados", MsgBoxStyle.YesNo, "Volver")
        If yes = 6 Then
            TodoACero()
            cadenaConexBD.Close()
            ' frmIndex.Show()
            Me.Close()
        End If
    End Sub
    Private Sub TodoACero()
        Limpiar(Gb_01)
        Limpiar(Gb_02)
        Limpiar(Gb_03)
        Limpiar(gbValores)

        PsaludoVTA = 0
        PempatiaVTA = 0
        PindagacionVTA = 0
        PmanejoVTA = 0
        PentusiasmoVTA = 0
        PspeechVTA = 0
        PpresentacionVTA = 0
        PmecanismoVTA = 0
        PpideVTA = 0
        puntajeTotalVTA = 0
        lbl_puntaje.Text = 0
        chkAlerta.Checked = False
    End Sub

    Private Sub cbo_empresa_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_empresa.SelectedIndexChanged
        auditadosXempresaVentas(cbo_auditado, cbo_empresa.Text)
        cbo_auditado.Text = "Seleccionar..."
    End Sub
End Class